package com.hgx.su.common.springboot.web.controller;

import com.hgx.su.common.springboot.web.config.SpringBootWebCommonConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Description: 服务健康
 * author: HGX
 * DateTime: 2020-12-21 20:10
 */
@RestController
@RequestMapping("/healthy")
public class ServiceHealthyController {

    @Value("${spring.application.name:unknown}")
    private String applicationName;
    @Resource
    private SpringBootWebCommonConfig commonConfig;

    @RequestMapping("heartbeat")
    public String heartbeat() {
        if (commonConfig.getApplicationName() != null && !"".equals(commonConfig.getApplicationName())) {
            return commonConfig.getApplicationName() + " is ok";
        }

        return applicationName + " is ok";
    }
}
